<style type="text/css">
 .img-review {width:390px;height: auto;min-height: 80px;}
</style>
<script type="text/javascript">
Do.add('common',{path:'__STATIC__/fastshop/common.js'});
Do('base','layer','form','common','date',function () {
    $('#form').isForm({'upload':'{:url("system/passport.common/upload")}'});
    $(".win").win({'url':'{:url("fastshop/item/select")}'});
    $(".is_fusion").change(function(){
        var id = $(this).val();
        if(0 == id){
            $(".item_title").text('销售产品:');
            $(".gift_title").text('赠送产品:');
        }else{
            $(".item_title").text('赠送产品:');
            $(".gift_title").text('销售产品:');
        }
    });    
    //增加商品属性
    var i = {$i};
    $('#add').click(function () {
        i++;
        $(".gift").before('<tr><th></th><td class="input-group">' +
            '<input autocomplete="off" onClick="winGift('+ i +')" datatype="n" class="readonly w100 win input gift_item_id_'+i+'" type="text" name="gift[item_id][]" />' +
            '<input autocomplete="off" id="gift_cost_price_'+ i +'"  datatype="npot" class="input w100" type="text" name="gift[cost_price][]" />' +
            '<input autocomplete="off" datatype="npot" class="input w100" type="text" name="gift[sale_price][]" />' +
            '<input autocomplete="off" datatype="npot" class="input w100" type="text" name="gift[market_price][]" /></div>' +
            '<div class="fn-left w50 fn-tac fn-cp" onClick="delGift(this)"><i class="iconfont icon-reduce_icon"></i></td></tr>'
        )
    })
})
//删除属性
function winGift(id) {
    openwin('{:url("fastshop/item/select")}?input='+id);
}
//删除属性
function delGift(dom) {
    $(dom).parents("tr").remove();
    $(dom).parent().remove();
}
//添加图片
function setImg(show_src){
    $("#img").val(show_src);
    $(".img-review").html('<img src="'+show_src+'">');  
}
//销售商品
function items(ids){
    $("#item_id").val(ids);
    $.getJSON("{:url('fastshop/item/getview')}",{id:ids},function(rel){
        $("#cost_price").val(rel.data.price);
        $("#entrust_number").text(rel.data.entrust_number);
        $("#sale_price").val('');
    });
}
//赠送产品一
function giftitem(ids,id){
    $(".gift_item_id_"+id).val(ids);
    $.getJSON("{:url('fastshop/item/getview')}",{id:ids},function(rel){
        $("#gift_cost_price_"+id).val(rel.data.price);
    });
}
</script>